
// console.log(window.location)
// if (window.location.hostname.includes('dygangs')){
//   let adLeft = document.getElementById('HMhrefleft');
//   let adRight = document.getElementById('HMhrefright');
//   let test = document.querySelector('#HMimageright')
//   console.dir(adLeft)
//   console.dir(adRight)
//   console.dir(test)
// }
// window.onload = function (){
//   console.log('window-onload')
//   let adLeft = document.getElementById('HMhrefleft');
//   let adRight = document.getElementById('HMhrefright');
//   let test = document.body.querySelectorAll('img')
//   console.log(test)
//   console.dir(document)
// }

function removeAD(){
  let adLeft = document.getElementById('HMhrefleft');
  let adRight = document.getElementById('HMhrefright');
  let adBottom = document.getElementById('HMrichA');
  console.dir(adBottom)
  let arr = [adLeft, adRight, adBottom];
  arr.forEach(dom => {
    if (dom && dom.style){
      dom.style.display = 'none';
    }
    if (dom && dom.id && dom.id.includes('HMrichA') && dom.parentElement){
      dom.parentElement.style.display = 'none';
    }
  })
}

// 消息监听
chrome.runtime.onMessage.addListener((message, sender, sendMessage) => {
  console.log(message);
  if (message.id === 'dygang'){
    removeAD();
  } 
});

